<%@ page pageEncoding="UTF-8"%>
<%@ page import="com.hwhp.entity.*"%>
<%@ page import="java.util.*"%>
<%@ page import="com.hwhp.common.Pager" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";
%>
<%
	List<Deptment> list=(List<Deptment> )request.getAttribute("subdeptList");
	String parentid=(String)request.getAttribute("parentid");
	String title = (String)request.getAttribute("title");
	if(title == null){
		title = "";
	}
	
	Pager pager = (Pager)request.getAttribute("page");
	if(pager != null){
		list = pager.getElements();
	}
 %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
	<HEAD>
		<LINK href="<%=basePath%>css/milkwhite.css" type=TEXT/CSS
			rel=StyleSheet></LINK>
		<LINK href="<%=basePath%>css/htmilkwhite.css" type=TEXT/CSS
			rel=StyleSheet></LINK>
		<LINK href="<%=basePath%>css/dhtmlxgrid.css" type=TEXT/CSS
			rel=StyleSheet></LINK>
		<SCRIPT src="<%=basePath%>js/list/dhtmlxcommon.js"
			type=text/javascript></SCRIPT>
		<SCRIPT src="<%=basePath%>js/list/dhtmlxgrid.js" type=text/javascript></SCRIPT>
		<SCRIPT src="<%=basePath%>js/list/dhtmlxgridcell.js"
			type=text/javascript></SCRIPT>
		<SCRIPT src="<%=basePath%>js/list/dhtmlxgrid_start.js"
			type=text/javascript></SCRIPT>
	</HEAD>
	<BODY style="MARGIN: 0px; OVERFLOW: visible">
		<FORM id="formlist" name="formlist" action="/chis/manager/depart!departList.action?act=search&parentid=<%=parentid%>" method="post">
			<TABLE height="100%" cellSpacing=0 cellPadding=0 width="100%"
				border=0>
				<TBODY>
					<TR>
						<TD height=20></TD>
						<TD height=20></TD>
						<TD height=20></TD>
					</TR>
					<TR>
						<TD class=middlelinel></TD>
						<TD height=20>
							<!-- 搜索 -->
							<TABLE cellSpacing=0 cellPadding=0 border=0 width="100%">
								<TBODY>
									<TR>
										<TD style="WIDTH: 70px" align=right>
											部门名称:
										</TD>
										<TD style="WIDTH: 80px" align=right>
											<INPUT id="title" name="title" value="<%=title%>" >
										</TD>
										<TD style="WIDTH: 8px"></TD>
										<TD class=searchheight>
											<TABLE class=button onmouseover="this.className='buthot'"
												onmouseout="this.className='button'" cellSpacing=0
												cellPadding=0 border=0>
												<TBODY>
													<TR onclick=document.forms[0].submit();>
														<TD class=buttoncelerity></TD>
														<TD class=buttonmiddle>
															检索
														</TD>
														<TD class=buttonright></TD>
													</TR>
												</TBODY>
											</TABLE>
										</TD>
										<TD width=5></TD>
										<TD>
											<span onclick="changePageNumber(1)" style="cursor: hand;">首页</span>
											<span onclick="changePageNumber(<%=pager.getPageNumber()-1%>)" style="cursor: hand;">上页</span>
											<input type="text" style="width: 50px;" name="pageNumber" id="pageNumber"  value="<%=pager.getPageNumber()%>"><span onclick="changeSelfPageNumber()" style="cursor: hand;">go</span>
											<span onclick="changePageNumber(<%=pager.getPageNumber()+1%>)" style="cursor: hand;">下页</span>
											<span onclick="changePageNumber(<%=pager.getLastPageNumber()%>)" style="cursor: hand;">末页</span>
											 共
											<B><%=pager.getTotalElements()%></B> 条
										</TD>
										<TD vAlign=top align="right">
											<table border='0' cellpadding='2' cellspacing='0'>
												<tr height="20">
													<td
														style='background-image:url(<%=basePath%>images/button/w_buttoncelerity1.gif);width:22px;'></td>
													<td
														style='background-image:url(<%=basePath%>images/button/w_buttonmiddle1.gif);cursor: hand;'
														onclick="addProcess()">
														<a href="/chis/manager/depart!departEdit.action?act=add&parentid=<%=parentid%>">新增</a>
													</td>
													<td
														style='background-image:url(<%=basePath%>images/button/w_buttonright1.gif);width:6px;'></td>
													<td
														style='background-image:url(<%=basePath%>images/button/w_buttonclose1.gif);width:22px;'></td>
													<td
														style='background-image:url(<%=basePath%>images/button/w_buttonmiddle1.gif);cursor: hand;'
														onclick="updateProcess()">
														修改
													</td>
													<td
														style='background-image:url(<%=basePath%>images/button/w_buttonright1.gif);width:6px;'></td>
													<td
														style='background-image:url(<%=basePath%>images/button/w_buttondelete1.gif);width:22px;'></td>
													<td
														style='background-image:url(<%=basePath%>images/button/w_buttonmiddle1.gif);cursor: hand;'
														onclick="deleteProcess()">
														删除
													</td>
													<td
														style='background-image:url(<%=basePath%>images/button/w_buttonright1.gif);width:6px;'></td>
												</tr>
											</table>
										</TD>
									</TR>
								</TBODY>
							</TABLE>
						</TD>
						<TD class=middleliner></TD>
					</TR>
					<TR>
						<TD class=middlelinel></TD>
						<TD
							style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; BORDER-LEFT: 1px solid; BORDER-BOTTOM: 1px solid"
							vAlign=top>
							<TABLE class=dhtmlxGrid id=gridbox height="100%" width="100%">
								<TBODY>
									<TR>
									    <TD noWrap type="ro" style="width:30">
									       <INPUT class=input3 id=alldepartid name=departid value="" type="checkbox">
										</TD>
									    <TD noWrap type="ro" style="width:50">
									       序号
										</TD>
										<TD noWrap type="ro">
											部门名称
										</TD>
										<TD noWrap type="ro">
											部门编码
										</TD>
										<TD noWrap type="ro" style="width:80">
											操作
										</TD>
									</TR>
									<%
									 if(list!=null&&list.size()>0){
									  int i=1;
									  for(Deptment deptObj:list){
									 %>
									<TR>
									    <TD noWrap>
									       <INPUT class=input3 id=alldepartid name=departid value="" type="checkbox">
										</TD>
									    <TD noWrap align="center">
									       <%=i%>
										</TD>
										<TD noWrap>
										    <%="".equals(deptObj.getDeptName())?"无":deptObj.getDeptName() %>
										</TD>
										<TD noWrap>
											<%="".equals(deptObj.getDeptCode())?"无":deptObj.getDeptCode() %>
										</TD>
										<TD noWrap align="center">
											<img src="<%=basePath%>images/button/edit.gif" style="cursor: hand" onclick="editProcess('<%=deptObj.getDeptId() %>')">&nbsp;&nbsp;
											<img src="<%=basePath%>images/button/del.gif" title="删除" style="cursor: hand" onclick="deleteProcess('<%=deptObj.getDeptId() %>','<%=parentid%>')">
										</TD>
									</TR>
									<%
									 i++;
									 }
									 }else{
									 %>
									 
									 <%
									 }
									  %>
								</TBODY>
							</TABLE>
						</TD>
					<TD class=middleliner></TD>
					</TR>
					<TR>
						<TD class=middlebottoml></TD>
						<TD class=middlebottomm></TD>
						<TD class=middlebottomr></TD>
					</TR>
				</TBODY>
			</TABLE>
		</FORM>
	</BODY>
	<SCRIPT type=text/javascript>
		function editProcess(deptid){
		  formlist.action="/chis/manager/depart!departEdit.action?deptid="+deptid+"&act=edit";
		  formlist.submit();
		}
		
		function deleteProcess(deptid,parentid){
		  formlist.action="/chis/manager/depart!deleteDepart.action?deptid="+deptid+"&parentid="+parentid;
		  formlist.submit();
		}
		function changeSelfPageNumber(){
			var pageN = document.getElementById("pageNumber");
			if(pageN < 1){
				alert("不能向上翻页");
			}else if(pageN ><%=pager.getLastPageNumber()%>){
				alert("不能向下翻页");	
			}else{
				document.forms[0].submit();
			}
		}
		function changePageNumber(pageNum){
			if(pageNum < 1){
				alert("不能向上翻页");
			}else if(pageNum ><%=pager.getLastPageNumber()%>){
				alert("不能向下翻页");	
			}else{
				var pn = document.getElementById("pageNumber");
				pn.value = pageNum ;
				document.forms[0].submit();
			}
		}
	</SCRIPT>
</HTML>
